package com.feihong.yw189.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.jay.easykeyboard.constant.Util;

/**
 * @Author wangziheng
 * @ProjectName ywydt
 * @ClassName SpacesItemDecoration
 * @package com.feihong.yw189.view
 * @data 2019/3/4 18:47
 * @Describe
 * @Change
 */
public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
    int delta;
    Context mContext;
    public SpacesItemDecoration(Context context){
        delta = Util.dpToPx(context,5);
        mContext = context;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        if(parent.getChildAdapterPosition(view) % 4 == 0 ){
            outRect.left = 0;
            outRect.right = Util.dpToPx(mContext,7.5f);
        }else if(parent.getChildAdapterPosition(view) % 4 == 1 ){
            outRect.left = Util.dpToPx(mContext,2.5f);
            outRect.right = Util.dpToPx(mContext,7.5f);
        }else if(parent.getChildAdapterPosition(view) % 4 == 2 ){
            outRect.left = delta;
            outRect.right = Util.dpToPx(mContext,2.5f);
        }else if(parent.getChildAdapterPosition(view) % 4 == 3 ){
            outRect.right = 0;
            outRect.left = Util.dpToPx(mContext,7.5f);
        }
    }
}
